// components/navigator/navigator.js
import {
  updateUserInfo
} from "../../utils/api.js"
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // currentTab: {
    //   type: Number,
    //   value: 1,
    //   observer: function(newVal, oldVal) {
    //     this.setData({
    //       currentTab: newVal
    //     })
    //   }
    // },
    userInfo: {
      type: Object,
      value: {
        avatarUrl: "../../images/avatar.png"
      }
    },
    isIde: {
      type: Boolean,
      value: true
    }
  },


  data: {
    www: ''
  },

  methods: {

    num: function(e) {
      this.setData({
        input: e.detail.value
      })
    },

    btn: function() {
      var www = ''
      if (this.data.input) {

        wx.navigateTo({
          url: '../../pages/select/select'
        })
        wx.setStorageSync(www, this.data.input)
      }




    },


    _onGotUserInfo: function(res) {
      var that = this;
      console.log(res.detail.userInfo);
      console.log('舅舅家');
      wx.setStorageSync('userInfo', res.detail.userInfo);
      res.detail.userInfo.openid = wx.getStorageSync('openid');
      updateUserInfo(res.detail.userInfo, function(res2) {
        if (res2.errcode == 0 && res2.errmsg == "success") {
          that.setData({
            userInfo: res.detail.userInfo,
            isIde: false
          })
          wx.showToast({
            title: '授权成功',
            icon: "success",
            duration: 1500
          })
        } else {
          console.log("提交失败")
        }
      });
    }
  }
})